<template>
	<div>
		<div class="word-container">
			<div class="forts">
				学生信息录入
				<el-button @click='goBack()' class="back-button">
					返回首页
				</el-button>
			</div>
			<Time class="forts-time" />
		</div>
		<!-- 学号输入框 -->
		<div class="select-info-bar">
			<el-form ref="table" :model="tableData" label-width="80px">
				<el-form-item label="学号">
					<el-input v-model="tableData.Sno"></el-input>
				</el-form-item>
				<el-form-item label="姓名">
					<el-input v-model="tableData.Sname"></el-input>
				</el-form-item>
				<el-form-item label="性别">
					<el-input v-model="tableData.Ssex"></el-input>
				</el-form-item>
				<el-form-item label="年龄">
					<el-input v-model="tableData.Sage"></el-input>
				</el-form-item>
				<el-form-item label="民族">
					<el-input v-model="tableData.Snation"></el-input>
				</el-form-item>
				<el-form-item label="生源地">
					<el-input v-model="tableData.Slocation"></el-input>
				</el-form-item>
				<el-form-item label="学制">
					<el-input v-model="tableData.Sacademic"></el-input>
				</el-form-item>
				<el-form-item label="专业">
					<el-input v-model="tableData.Smajor"></el-input>
				</el-form-item>
				<el-form-item label="政治面貌">
					<el-input v-model="tableData.Spolitic"></el-input>
				</el-form-item>
				<el-form-item label="奖惩记录">
					<el-input v-model="tableData.Srecord"></el-input>
				</el-form-item>
				<el-form-item label="转修复退学标记">
					<el-input v-model="tableData.Smark"></el-input>
				</el-form-item>
			</el-form>
		</div>
		<div class="buttom-commit">
			<el-button @click='insert(tableData)' type="primary">提交</el-button>
		</div>
		<img src="../assets/logo.png" alt="" />
	</div>
</template>

<script>
	import {
		ElMessage
	} from 'element-plus'
	import Time from "./Time.vue";
	import {
		defineComponent,
		ref
	} from 'vue';
	export default {
		name: "StudentInsert",
		components: {
			Time,
			defineComponent,
			ref,
		},
		// 数据获取
		data() {
			return {
				tableData: {
					Sno: '',
					Sname: '',
					Ssex: '',
					Sage: '',
					Slocation: '',
					Snation: '',
					Spolitic: '',
					Smajor: '',
					Sacademic: '',
					Srecord: '',
					Smark: '',
				},
			}
		},
		methods: {
			goBack() {
				//直接跳转
				this.$router.push('/main');
			},
			insert(row) {
				ElMessage.success({
						message: '插入成功',
						type: 'success',
					})
					this.axios.post('http://localhost:8081/info/insert', {
					sno: row.Sno,
					sname: row.Sname,
					ssex: row.Ssex,
					sage: row.Sage,
					slocation: row.Slocation,
					snation: row.Snation,
					spolitic: row.Spolitic,
					smajor: row.Smajor,
					sacademic: row.Sacademic,
					srecord: row.Srecord,
					smark: row.Smark
				}).then(response => {
					response.log(data)
				})
			}
		},
	}
</script>

<style>
	.select-info-bar {
		width: 30%;
		position: absolute;
		left: 20%;
		top: 12%;
	}

	.buttom-commit {
		width: 30%;
		position: absolute;
		left: 60%;
		top: 85%;
	}
</style>
